﻿#Question 5
#
#Getting the list of Installed Item from Win32_Product
$Installed = get-wmiobject -class "Win32_Product" -namespace "root\CIMV2" -computername .

#Geeting the Time taken to get the Installed Item
$Time = get-wmiobject -class “Win32_LocalTime” -namespace “root\CIMV2" -computername .

#Declaring the variable Line and i
$Line = "/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\"
$i=0

#Getting the seconds taken to list the Installed Programs
foreach($objItem in $Time)
{
$seconds= $objItem.Second
}

#Getting the list the Installed Programs and incrementing the Counter
foreach ($objItem in $Installed) 
{
 $i=$i+1
}

#Echo the output
echo ""
echo $Line
echo $Line

echo "Counting Installed Products. This may take a litte while."

echo "There are $i products Installed."
echo "It took $seconds seconds for this script to complete."
echo ""
